//
//  ZhuangxiuManager.m
//  haojia
//
//  Created by 方伟 on 16/5/11.
//  Copyright © 2016年 徐宏飞. All rights reserved.
//

#import "ZhuangxiuManager.h"

static ZhuangxiuManager *instance = nil;

@implementation ZhuangxiuManager

+(instancetype)shareManager
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[super allocWithZone:nil] init];
        
    });
    
    [instance _changedata];
    return instance;
}

+(instancetype)allocWithZone:(struct _NSZone *)zone
{
    return [self shareManager];
}

-(id)copy
{
    return self;
}

-(void)setLoginSucceed:(NSString *)loginSucceed{

    _loginSucceed = loginSucceed;
//    
//    //更改本地
//    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
//    if (loginSucceed) {
//        NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:
//                             @YES,@"loginSucceed" ,
//                             _mobile,@"mobile",
//                             _sessionid,@"sessionid",
//                             nil];
//        [defaults setObject:dic forKey:@"loginData"];
//    } else {
//        NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:
//                             @NO,@"loginSucceed" ,
//                             _mobile,@"mobile",
//                             _sessionid,@"sessionid",
//                             nil];
//        [defaults setObject:dic forKey:@"loginData"];
//    }
    
}


-(void) _changedata{
    
    //取出本地保存的认证信息
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSDictionary *loginData = [defaults objectForKey:@"loginData"];
    self.mobile = [defaults objectForKey:@"mobile"];
    self.channel_id =[defaults objectForKey:@"channel_id"];
    if (_channel_id.length==0) {
        self.channel_id = @"-1";
    }
    if ([[loginData objectForKey:@"loginSucceed"]intValue]>0 )
    {
    
        self.worker_id = [loginData objectForKey:@"worker_id"];

        self.sessionid = [loginData objectForKey:@"sessionid"];
        self.loginSucceed = [loginData objectForKey:@"loginSucceed"];
//        self.loginSucceed = mun.boolValue;
    }else{
    
        self.worker_id = @"-1";

    
    }
    
    
}



@end
